# -*- coding: utf-8 -*-
# @Time    : 2022/1/11 11:00
# @Author  : 徐翊宸
# @Email   : xyc@163.com
# @File    : page_grzl.py
# @Software: PyCharm


from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from pages.base_page import BasePage

class GrzlPage(BasePage):

    tx_submit_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div.span3.knowledgecate > div > div.personal-panel > div:nth-child(1) > a > img")
    name_locator = (By.NAME, "name")
    mima_locator = (By.CSS_SELECTOR, "#password")
    yhlb_locator = (By.CSS_SELECTOR, "#category_id")
    bumen_locator = (By.CSS_SELECTOR, "#department")
    sex_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(2) > form > table > tbody > tr:nth-child(10) > td:nth-child(2) > input[type=radio]:nth-child(2)")
    youxiang_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(2) > form > table > tbody > tr:nth-child(11) > td:nth-child(2) > input")
    phone_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(2) > form > table > tbody > tr:nth-child(12) > td:nth-child(2) > input")
    dizi_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(2) > form > table > tbody > tr:nth-child(13) > td:nth-child(2) > textarea")
    baocun_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(2) > form > table > tfoot > tr > td:nth-child(2) > input.btn.btn-primary")


    def __int__(self, driver):
        self.driver = driver

    def tx_submit_click(self):
        self.driver.find_element(*self.tx_submit_locator).click()

    def name_input(self, name):
        self.driver.find_element(*self.name_locator).clear()
        self.driver.find_element(*self.name_locator).send_keys(name)

    def mima_input(self,mima):
        self.driver.find_element(*self.mima_locator).send_keys(mima)

    def yhlb_xz(self):
        yhlb_select_element = self.driver.find_element(*self.yhlb_locator)
        yhlb_select = Select(yhlb_select_element)
        yhlb_select.select_by_index(1)

    def bumen_xz(self):
        bumen_select_elment = self.driver.find_element(*self.bumen_locator)
        bumen_select = Select(bumen_select_elment)
        bumen_select.select_by_index(2)

    def sex_click(self):
        self.driver.find_element(*self.sex_locator).click()

    def youxiang_input(self, youxiang):
        self.driver.find_element(*self.youxiang_locator).clear()
        self.driver.find_element(*self.youxiang_locator).send_keys(youxiang)

    def phone_input(self, phone):
        self.driver.find_element(*self.phone_locator).clear()
        self.driver.find_element(*self.phone_locator).send_keys(phone)

    def dizi_input(self, dizi):
        self.driver.find_element(*self.dizi_locator).clear()
        self.driver.find_element(*self.dizi_locator).send_keys(dizi)

    def baocun_click(self):
        self.driver.find_element(*self.baocun_locator).click()





